import axios from 'axios'
import MockAdapter from 'axios-mock-adapter'

const mock = new MockAdapter(axios)

// 仪表盘数据
mock.onGet('/api/dashboard').reply(200, {
  code: 200,
  data: {
    dailyNutrition: {
      calories: 2100,
      protein: 75,
      carbs: 280,
      fat: 70,
      caloriesProgress: 84,
      proteinProgress: 94,
      carbsProgress: 93,
      fatProgress: 108
    },
    weightTrend: [
      { date: '2024-03-01', weight: 65.5 },
      { date: '2024-03-02', weight: 65.3 },
      { date: '2024-03-03', weight: 65.2 },
      { date: '2024-03-04', weight: 65.0 },
      { date: '2024-03-05', weight: 64.8 },
      { date: '2024-03-06', weight: 64.7 },
      { date: '2024-03-07', weight: 64.5 }
    ],
    goalProgress: {
      type: '减重目标',
      target: '减重5kg',
      current: '已完成3kg',
      percentage: 60,
      status: 'success',
      statusText: '进行中'
    },
    recentMeals: [
      {
        id: 1,
        type: '早餐',
        time: '08:00',
        description: '全麦面包 + 牛奶 + 鸡蛋',
        calories: 350,
        protein: 15,
        carbs: 45,
        fat: 12
      },
      {
        id: 2,
        type: '午餐',
        time: '12:30',
        description: '糙米饭 + 清炒西兰花 + 煎鸡胸肉',
        calories: 450,
        protein: 35,
        carbs: 55,
        fat: 10
      }
    ]
  },
  message: '获取成功'
})

// 登录接口
mock.onPost('/api/user/login').reply(200, {
  code: 200,
  data: {
    token: 'mock-token',
    userInfo: {
      id: 1,
      username: 'demo',
      nickname: '演示用户',
      email: 'demo@example.com',
      avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
      gender: 'male',
      birthday: '1990-01-01',
      height: 175,
      weight: 65,
      activityLevel: 'moderately_active',
      goal: 'lose_weight'
    }
  },
  message: '登录成功'
})

// 获取用户信息
mock.onGet('/api/user/info').reply(200, {
  code: 200,
  data: {
    id: 1,
    username: 'demo',
    nickname: '演示用户',
    email: 'demo@example.com',
    avatar: 'https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png',
    gender: 'male',
    birthday: '1990-01-01',
    height: 175,
    weight: 65,
    activityLevel: 'moderately_active',
    goal: 'lose_weight'
  },
  message: '获取成功'
})

export default mock 